<link type="text/css" href="/admins/js/jquery/css/ui-lightness/jquery-ui-1.8.20.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/admins/js/My97DatePicker/WdatePicker.js"></script>
<div class="admin_nrtop">
    <div class="ad_search" style="height: 30px;">
        <form action="/admini/remotefee/index/"  method="get" style="margin:0px;font-size: 16px;" id="form1">
            <div style="margin-top: 10px;">
                <input type="hidden" name="stateId" id="stateId" value="<?php echo $this->stateId;?>"/>
                <div style="position: relative;margin-top: -10px;float: left;" id="state_div">
                  <div class="guyojiatext">
                        国家：<?= $this->formText('cityName',$this->stateName,array('readonly'=>true,'cid'=>1,'style'=>"font-size:16px;")) ?>
                        <a href="javascript:void(0)"></a>
                        
                  </div>
                  <div class="guojiaceng" style="display:none;top:24px;z-index: 40000;">
                      <div class="remen">
                          <h2>热门国家和地区</h2>
                          <ul class="countrylist">
                              <li><a href="javascript:void(0)" id="c_us" cid="1">美国</a></li>
                              <li><a href="javascript:void(0)" cid="2">加拿大</a></li>
                              <li><a href="javascript:void(0)" cid="3">澳大利亚</a></li>
                              <li><a href="javascript:void(0)" cid="47">日本</a></li>
                              <li><a href="javascript:void(0)" cid="39">台湾</a></li>
                              <li><a href="javascript:void(0)" cid="4">新西兰</a></li>
                              <li><a href="javascript:void(0)" cid="5">英国</a></li>
                              <li><a href="javascript:void(0)" cid="42">马来西亚</a></li>
                          </ul>
                      </div>
                      <div class="allcountry">
                          <h2>全部国家和地区</h2>
                          <ul class="countryzm">
                              <? foreach ($this->words as $char) { ?>
                                  <li <?= $char == 'A' ? 'class="zmon"' : '' ?>><a href="javascript:void(0)"><?= $char ?></a></li>
                              <? } ?>
                          </ul>
                          <div id="countryTab">
                              <? foreach ($this->words as $char) { ?>
                                  <ul class="countrylist"  <?= $char == 'A' ? '' : 'style="display:none"' ?>>
                                      <?
                                      $citys = Application_Model_city::GetBySortCode($char);
                                      foreach ($citys as $city) {
                                          ?>
                                          <li><a href="javascript:void(0)" cid="<?= $city->Id ?>"><?= $city->Name ?></a></li>
                                  <? } ?>
                                  </ul>
                             <? } ?>
                          </div>
                      </div>
                  </div>
                </div>
                <div style="float: left;margin-left: 10px;margin-top: -10px;">
                    <label for="startZip">邮编：</label><input type="text" id="startZip" name="startZip"  value="<?php echo $this->startZip;?>" style="font-size:16px;"/>
                    <label for="endZip">--&nbsp;</label><input type="text" id="endZip" name="endZip"  value="<?php echo $this->endZip;?>" style="font-size:16px;"/>
                    <input type="submit" id="queryButton" value="查询" style="font-size: 16px;"/>
                </div>
            </div>
        </form>
    </div> 
</div>
<div style="width: 100%;">
<div class="biaoge" style="float: left;width:500px;">
    <div class="biaotbody">
        <table>
            <tr>
                <th class="li4">
                    <div class="lileft">&nbsp;</div>
                </th>
                <th class="li10">
                    <div class="lileft"><span>&nbsp;&nbsp;国家</span></div>
                </th>
                <th class="li10">
                    <div class="lileft"><span>开始邮编</span></div>
                </th>
                <th class="li10">
                    <div class="lileft"><span>结束邮编</span></div>
                </th>
                <th class="li10">
                    <div class="lileft" style="margin-left: 20px;"><span>操作</span></div>
                </th>
            </tr>
        </table>
    </div>
    <div class="table">
        <table>
             <?php  if($this->remoteList){ $i = 0;
                foreach ($this->remoteList as $Item) { ?> 
                 <tr>
                     <td class="li4">&nbsp;</td>
                     <td class="li10">
                         <div class="lileft">
                             <?php echo $Item->StateName;?>
                         </div>
                     </td>
                     <td class="li10">
                         <div class="lileft" style="margin-left: 20px;">
                             <?php echo $Item->StartZip;?>
                         </div>
                     </td>
                     <td class="li10">
                         <div class="lileft" style="margin-left: 20px;">
                             <?php echo $Item->EndZip;?>
                        </div>
                     </td>
                     <td class="li10">
                         <div class="lixlnav">
                             <a class="xlnavxq" href="javascript:void(0);"  name="<?= $Item->id ?>">修改</a>
                             <div class="xlnavlistbox">
                                 <a class="xlnavsj" href="javascript:void(0);"><i></i></a>
                                 <div class="xlnavlist" style="display:none;">
                                     <ul>
                                          <li><a href="javascript:void(this)" class="delremotefeebyid" name="<?= $Item->id ?>">删除</a></li>
                                     </ul>
                                 </div>
                             </div>
                         </div>
                     </td>
                 </tr>
                 <?php $i++;
                    if($i == 20 || $i == 40){ ?>
                        </table>
                        </div>
                        </div>
                        <div class="biaoge" style="float: left;width:500px;">
                        <div class="biaotbody">
                            <table>
                                <tr>
                                    <th class="li4">
                                        <div class="lileft">&nbsp;</div>
                                    </th>
                                    <th class="li10">
                                        <div class="lileft"><span>&nbsp;&nbsp;国家</span></div>
                                    </th>
                                    <th class="li10">
                                        <div class="lileft"><span>开始邮编</span></div>
                                    </th>
                                    <th class="li10">
                                        <div class="lileft"><span>结束邮编</span></div>
                                    </th>
                                    <th class="li10">
                                        <div class="lileft" style="margin-left: 20px;"><span>操作</span></div>
                                    </th>
                                </tr>
                            </table>
                        </div>
                        <div class="table">
                            <table>
                 <?php } ?>
             <?php } }  if(!$this->remoteAll){
                echo "<font size='4' color='red'>暂无数据</font>";
                }?>   
         </table>
     </div>
 </div>
</div>
<div class="toolbar">
    <div class="qunx">
        <ul>
            <li><a class="anvbotton" href="javascript:void(0)" id="addRemote" name="addRemote"><span>添加偏远费</span></a></li>
        </ul>
    </div>
<?php
    echo $this->partial('paging.phtml', array("pages" => $this->remoteAll,"pamas"=>"stateId=$this->stateId&startZip=$this->startZip&endZip=$this->endZip"));        
?>
</div>
<div class="tanchuang" style="display:none;height: 300px;">
    <div class="nui-msgbox">
        <div class="nui-msgbox-hd" id="wayProblem">添加偏远费</div>
        <a class="nui-msgbox-close" title="关闭"><b></b></a>
    </div>
    <div class="wenti_box" id="problemComm">
            <div style="margin-left:50px;margin-top: 15px;margin-bottom: 5px;font-size: 14px;">
                <table id="add_table">
                    <tr style="height: 36px;">
                        <td align="right">国家：</td>
                        <td><div style="margin-top: 10px;">
                            <input type="hidden" name="addstateId" id="addstateId" value="1"/>
                            <div style="position: relative;margin-top: -10px;float: left;" id="state_adddiv">
                              <div class="guyojiatext">
                                    <?= $this->formText('addCityName',"美国",array('readonly'=>true,'cid'=>1,'style'=>"font-size:16px;")) ?>
                                    <a href="javascript:void(0)"></a>
                              </div>
                              <div class="guojiaceng" style="display:none;top:20px;z-index: 40000;">
                                  <div class="remen">
                                      <h2>热门国家和地区</h2>
                                      <ul class="countrylist">
                                          <li><a href="javascript:void(0)" id="c_us" cid="1">美国</a></li>
                                          <li><a href="javascript:void(0)" cid="2">加拿大</a></li>
                                          <li><a href="javascript:void(0)" cid="3">澳大利亚</a></li>
                                          <li><a href="javascript:void(0)" cid="47">日本</a></li>
                                          <li><a href="javascript:void(0)" cid="39">台湾</a></li>
                                          <li><a href="javascript:void(0)" cid="4">新西兰</a></li>
                                          <li><a href="javascript:void(0)" cid="5">英国</a></li>
                                          <li><a href="javascript:void(0)" cid="42">马来西亚</a></li>
                                      </ul>
                                  </div>
                                  <div class="allcountry">
                                      <h2>全部国家和地区</h2>
                                      <ul class="countryzm">
                                          <? foreach ($this->words as $char) { ?>
                                              <li <?= $char == 'A' ? 'class="zmon"' : '' ?>><a href="javascript:void(0)"><?= $char ?></a></li>
                                          <? } ?>
                                      </ul>
                                      <div id="countryTab">
                                          <? foreach ($this->words as $char) { ?>
                                              <ul class="countrylist"  <?= $char == 'A' ? '' : 'style="display:none"' ?>>
                                                  <?
                                                  $citys = Application_Model_city::GetBySortCode($char);
                                                  foreach ($citys as $city) {
                                                      ?>
                                                      <li><a href="javascript:void(0)" cid="<?= $city->Id ?>"><?= $city->Name ?></a></li>
                                              <? } ?>
                                              </ul>
                                         <? } ?>
                                      </div>
                                  </div>
                              </div>
                            </div>
                        </div></td>
                    </tr>
                    <tr style="height: 36px;">
                        <td align="right">开始邮编：</td>
                        <td><input type="text" id="addStartZip" name="addStartZip" value="" style="font-size:16px;"/></td>
                    </tr>
                    <tr style="height: 36px;">
                        <td align="right">结束邮编：</td>
                        <td><input type="text" id="addEndZip" name="addEndZip" value="" style="font-size:16px;"/></td>
                    </tr>
                    <tr style="height: 36px;">
                        <td align="center" colspan="4">
                            <input type="hidden" id="editId" name="editId" value="" />
                            <input type="button" id="navigationAdd" naem="navigationAdd" value="添加" style="background-color: #F60;width: 50px;height: 36px;color: white;font-size: 16px;border-radius:8px;"/>
                            &nbsp;&nbsp;<input type="button" id="refo" naem="refo" value="返回" style="background-color: #1668A4;width: 50px;height: 36px;color: white;font-size: 16px;border-radius:8px;"/>
                        </td>
                    </tr>
                </table>
            </div>
    </div>
</div>
<div class="houtai_overlay" style="display:none;"></div>
<script>
    $(".xlnavsj").live("mousemove",function(){
        $(this).next("div").show();
    });
    $(".lixlnav").mouseleave(function(){
        $(".xlnavsj").next("div").hide();
    });
    $('#state_div').hover(function(){
    },function(){
        $('#state_div .guojiaceng').hide();
    }).click(function(){
        $('#state_div .guojiaceng').show();
    });
    $('#state_div .countrylist a').bind('click',function(){
        var city =$(this).text();
        var state = $(this).attr("cid");
        $("#stateId").val(state);
        $("#state_div #cityName").val(city);
        $('#state_div .guojiaceng').hide();
        return false;
    });
    $('#state_div .countryzm a').each(function(index,item){
        $(item).click(function(){
            $('#state_div .countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#state_div #countryTab ul').hide();
            $('#state_div #countryTab ul').eq(index).show();
            return false;
        });
    });
     $("#addRemote").click(function(){
        $(".houtai_overlay").show();
        $(".tanchuang").show();
    });
    $(".nui-msgbox-close").click(function(){
        $(".houtai_overlay").hide();
        $(".tanchuang").hide();
        $("#editId").val("");
        $("#addstateId").val("1");
        $("#addStartZip").val("");
        $("#addEndZip").val("");
        $("#addCityName").val("美国");
    });
    $("#refo").click(function(){
        $(".nui-msgbox-close").click();
    });
    $('#state_adddiv').hover(function(){
    },function(){
        $('#state_adddiv .guojiaceng').hide();
    }).click(function(){
        $('#state_adddiv .guojiaceng').show();
    });
    $('#state_adddiv .countrylist a').bind('click',function(){
        var city =$(this).text();
        var state = $(this).attr("cid");
        $("#addstateId").val(state);
        $("#state_adddiv #addCityName").val(city);
        $('#state_adddiv .guojiaceng').hide();
        return false;
    });
    $('#state_adddiv .countryzm a').each(function(index,item){
        $(item).click(function(){
            $('#state_adddiv .countryzm li.zmon').removeClass('zmon');
            $(this).parent().addClass('zmon');
            $('#state_adddiv #countryTab ul').hide();
            $('#state_adddiv #countryTab ul').eq(index).show();
            return false;
        });
    });
    $("#navigationAdd").click(function(){
        var editId = $("#editId").val();
        var addstateId = $("#addstateId").val();
        var addStartZip = $("#addStartZip").val();
        var addEndZip = $("#addEndZip").val();
        if(addstateId == ""){
            alert("国家不能为空");
            return ;
        }
        if(addStartZip == ""){
            alert("开始邮编不能为空");
            return ;
        }
        if(addEndZip == ""){
            alert("结束不能为空");
            return ;
        }
        $.post('/admini/remotefee/addoreditremotefee', {'editId':editId,'addstateId':addstateId,'addStartZip':addStartZip,'addEndZip':addEndZip}, function(sj){
             if(sj == 1){
                 if(editId == ""){
                    alert("添加成功！");
                 } else {
                    alert("修改成功！");
                 }
                 location.reload();
             }else{
                 alert("出现未知错误");
             }
        }, 'json');
       
    });
    $(".xlnavxq").click(function(){
       var editId = $(this).attr("name");
       $.post('/admini/remotefee/remotefeeinfo', {'editId':editId}, function(sj){
             if(sj.type == 1){
                $("#editId").val(editId);
                $("#addstateId").val(sj.stateId);
                $("#addStartZip").val(sj.startZip);
                $("#addEndZip").val(sj.endZip);
                $("#addCityName").val(sj.stateName);
                $(".houtai_overlay").show();
                $(".tanchuang").show();
             }else{
                 alert("出现未知错误");
             }
        }, 'json');
    });
    $(".delremotefeebyid").click(function(){
        var delId = $(this).attr("name");
        $.post('/admini/remotefee/delremotefee', {'delId':delId}, function(sj){
            if(sj == 1){
                alert("删除成功！");
                location.reload();
            }else{
                alert("出现未知错误");
            }
        }, 'json');
    });
</script>